require(['config'], () => {
  require(['jquery'], ($) => {
    class registerPage {
      constructor() {
        this.add()
      }
      add () {
        $('.btn').on('click', () => {
          const _username = $('.username').val(), _password = $('.password').val(),
            _nickname = $('.nickname').val()
          $.ajax({
            url: 'http://localhost:3300/register.do',
            method: 'POST',
            data: {
              username: _username,
              password: _password,
              nickname: _nickname
            },
            success: resData => {
              console.log('成功', resData)
              const { code, message } = resData
              console.log(code, message)
              if (code === 200) {
                alert(message)
                location.href = 'login.html'
              } else {
                alert(message)
              }
            }
          })
        })
      }
    }
    new registerPage()
  })
})